<ul class="submenu">
	<li><?php echo anchor($this->curl . '/create', T_('New Account Type'), 'class="arrow-right"')?></li>
	<li><a href="javascript:void(0)" onclick="if (confirm('<?php echo T_('Are you sure you want to delete these data?'); ?>')) deleteItems('/admin/<?php echo $this->curl; ?>/deleteItems/');return false;"><?php echo T_('Delete Selected'); ?></a></li>
</ul>

<?php echo form_open('/' . $this->curl . '/index/', 'id="myform" name="myform"')?>

<table width="100%" border="0" cellpadding="3" cellspacing="0" id="grid" class="display">
<thead>
<tr>
	<th class="first"><?php echo form_checkbox('cid_toggle', null, FALSE, 'id="cid_toggle" onclick="toggleCheckboxes($(this))"')?></th>
	<th><?php echo T_('Name'); ?></th>
	<th><?php echo $this->account_type_model->fields['category'] ?></th>
	<th><?php echo $this->account_type_model->fields['description'] ?></th>
	<th><?php echo $this->account_type_model->fields['status'] ?></th>
	<th><?php echo T_('Edit'); ?></th>
	<th><?php echo T_('Permissions'); ?></th>
</tr>
</thead>
<tbody>
<?php foreach ($list as $row): ?>
<tr id="tr_<?php echo $row->id?>">
	<td class="t-center"><?php echo form_checkbox('cid[]', $row->id, FALSE, 'class="checkbox" id="cb'. $row->id.'"')?></td>
	<td class="account_type"><?php echo $row->name ?></td>
	<td>
	<?php 
		$cats = $this->config->item('account_categories');
		echo $cats[$row->category]; 
	?>
	</td>
	<td><?php echo $row->description ?></td>
	<td><?php if (!empty($this->account_type_model->status[$row->status])) echo $this->account_type_model->status[$row->status] ?></td>
	<td width="26" class="t-center"><?php echo anchor($this->curl.'/edit/'.$row->id, ' ', 'class="btn_edit" alt="'.T_('Edit').'" title="'.T_('Edit').'"')?></td>
	<td width="26" class="t-center"><?php echo anchor($this->curl.'/permissions/'.$row->id, ' ', 'class="btn_edit" alt="'.T_('Edit').'" title="'.T_('Permissions').'"')?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
	
<?php echo form_close()?>

<script type="text/javascript">
var oTable;

$(document).ready(function() {	
	$(".account_type").dblclick(function(){
		var tr_id = $(this).parent().attr('id');
		 location.href = '<?php echo $this->curl; ?>/edit/'+tr_id.substr(3);
	});
	
	/* Add a click handler to the rows - this could be used as a callback */
	$('#grid tr').click( function() {
		if ( $(this).hasClass('row_selected') )
		{			
			$(this).removeClass('row_selected');
			$(this).find('.checkbox').removeAttr('checked');
		}			
		else
		{
			$(this).addClass('row_selected');
			$(this).find('.checkbox').attr('checked', 'checked');
		}			
	});
		
	/* Init DataTables */
	oTable = $('#grid').dataTable(
	{	
		"aaSorting": [],				
		"aoColumns": [
  			{ "bSortable": false },
  			null,
  			null,
  			{ "bSortable": false },
  			null,
  			{ "bSortable": false },
  			{ "bSortable": false }
		],
																	
		"bPaginate": true,
		"bLengthChange": true,
		"bFilter": true,	
		"bSort": true,
		"bInfo": true,
		"bAutoWidth": true,
		"bJQueryUI": true,
		"sPaginationType": "full_numbers"	
	});
});	

/*
 * I don't actually use this here, but it is provided as it might be useful and demonstrates
 * getting the TR nodes from DataTables
 */
function fnGetSelected( oTableLocal )
{
	var aReturn = new Array();
	var aTrs = oTableLocal.fnGetNodes();
	
	for ( var i=0 ; i<aTrs.length ; i++ )
	{
		if ( $(aTrs[i]).hasClass('row_selected') )
		{
			aReturn.push( aTrs[i] );
		}
	}
	return aReturn;
}
</script>